package cc.yugu.yhdw.webserver.web.controller.security.hdw;

import cc.yugu.yhdw.common.annotation.ViewModel;
import cc.yugu.yhdw.common.domain.hdw.ItemOrder;
import cc.yugu.yhdw.common.entity.json.ExtResult;
import cc.yugu.yhdw.common.entity.json.PageResult;
import cc.yugu.yhdw.webserver.constant.AppConstEnum;
import cc.yugu.yhdw.webserver.service.hdw.ItemOrderService;
import cc.yugu.yhdw.webserver.web.controller.security.SecurityController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/security/hdw/item_order")
public class ItemOrderController extends SecurityController {
    @Autowired
    ItemOrderService itemOrderService;

    @RequestMapping(value = "index.htm")
    public void index(Model model) {
        model.addAttribute("orderStatusEnum", ItemOrder.OrderStatus.values());
        model.addAttribute(MENU_CODE_NAME, AppConstEnum.Menu.MENU_04_02.getValue());
    }

    @RequestMapping("page.htm")
    @ViewModel(ViewModel.JSON)
    @ResponseBody
    public PageResult page(ItemOrder orders) {
        return PageResult.successResult(itemOrderService.findPage(orders));
    }


    @ViewModel(ViewModel.INNER_PAGE)
    @RequestMapping("express.htm")
    public void express() {
    }

    @ResponseBody
    @ViewModel(ViewModel.JSON)
    @RequestMapping(value = "updateStatus.htm")
    public ExtResult create(ItemOrder entity) {
        return itemOrderService.updateOrderStatus(entity);
    }
}
